package org.langqiao.thread;

public class PriorityTest extends Thread{

	public PriorityTest(){
		
	}
	
	public PriorityTest(String name){
		super(name);
	}
	
	public void run(){
		for(int i=0;i<50;i++){
			System.out.println(getName()+",其优先级是："+getPriority() + ",循环变量为： " + i);
		}
	}
	
	public static void main(String[] args) {
		Thread.currentThread().setPriority(6);
		for(int i=0;i<30;i++){
			if(i==10){
				PriorityTest low = new PriorityTest("低级线程");
				low.start();
				System.out.println("低级线程创建之初的优先级为："+low.getPriority());
				low.setPriority(MIN_PRIORITY);
			}
			if(i==20){
				PriorityTest high = new PriorityTest("高级线程");
				high.start();
				System.out.println("高级线程创建之初的优先级为："+high.getPriority());
				high.setPriority(MAX_PRIORITY);
			}
		}
	}

}
